#include <vector>
#include "mapDM.h"
#include <iostream>
using namespace std;

Cut_C::Cut_C(vector<Node_C*> temp,int num):numofinput(num),group(temp)
{
	for(unsigned int i=0;i<group.size();++i)
	{
		group[i]->choose=1;
	}
	
	for(unsigned int i=0;i<group.size();++i)
	{
		for(unsigned int j=0;j<group[i]->input.size();++j)
		{
			if(group[i]->input[j]->choose==0)
				inode.push_back(group[i]->input[j]);
		}
	}
	
	for(unsigned int i=0;i<group.size();++i)
	{
		group[i]->choose=0;
	}

}

void Mapping_C::cut()
{
	vector<Node_C*>temp;
	temp.resize(3);
	Node_C* now;
	int numofinput=1;
	
	for(unsigned int i=m_vnode.size();i>=0;--i)
	{
		now=m_vnode[i];
		if(now->type==1) numofinput+=1; //type 1 = and;
		temp[2]=now;
		
		for(unsigned int j=0;j<m_vnode[i]->input.size();++j)
		{
			now=m_vnode[i]->input[j];
			if(now->type==1) numofinput+=1;
			temp[1]=now;
			
			for(unsigned int k=0;k<m_vnode[i]->input[j]->input.size();++k)
			{
				now=m_vnode[i]->input[j]->input[k];
				if(now->type==1) numofinput+=1;
				temp[0]=now;
				
				m_vnode[i]->cut.push_back(new Cut_C(temp,numofinput));
				if(now->type==1) numofinput-=1;
			}
			
			if(now->type==1) numofinput-=1;
		}
		
		if(now->type==1) numofinput-=1;
	
	}

}
